<?php require_once("includes/security.php"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="css/style.css">
<title>קליניקה נטורופתית</title>

<?php 	

require_once("includes/openConnection.php");

if(isset($_POST['submit'])) 
	{
	


			if($_POST['submit']=="הוסף") //  insert new text in project page
				{	
				if(mysql_query("INSERT INTO `clinic`.`external_links` (`id`, `link`, `link_desc`) VALUES (NULL, '{$_POST ['linkUrl']}', '{$_POST ['linkDesc']}');"))
				echo "הלינק התווסף בהצלחה" 
				or die ('could not updated:'.mysql_error());
				} 
			else if($_POST['submit']=="עדכן") //  update text in project page
				{

				if(mysql_query("UPDATE external_links SET  `link` =  '{$_POST ['link']}',
`link_desc` =  '{$_POST ['link_desc']}' WHERE  `external_links`.`id` ='{$_POST ['linkID']}';"))
				echo "הלינק עודכן בהצלחה";
				else
				echo "הלינק לא עודכן";
				}
						// end upload project files
			else if($_POST['submit']=="מחק")
			{
				if(mysql_query("DELETE FROM external_links WHERE ID ='{$_POST ['linkID']}'"))
							echo "הלינק נמחק בהצלחה";
							else
							echo "הלינק לא נמחק";
		
			}
		
}//end submit
	

?>

</head>

<body>
<container id="container">
  <?php require("header.php"); ?>
      <content id="content">
      <contentTitle id="contentTitle">
     הוספה והסרה של קישורים לצמחי מרפא
      </contentTitle>
      <contentText id="contentText">
    <subContentTitle id="subContentTitle">הוספת לינק</subContentTitle>			
<form name="form" action="#" method="post" enctype="multipart/form-data">
<table >
        <tr>
            <td>
            לינק:
            </td>
            <td >
             <input type="text"  id="linkUrl" name="linkUrl" value="" size="120" >
            <td>
   		</tr>
        <tr>
            <td>
            תיאור הלינק:
            </td>
            <td >
             <input type="text"  id="linkDesc" name="linkDesc" value="" size="120" >
            <td>
   		</tr>
        <tr>
            <td>
            <input type="submit" name="submit" value="הוסף" /> 
            </td>
    	</tr>
</table>
</form>
    
 <subContentTitle id="subContentTitle">עריכה ומחיקת לינקים</subContentTitle>	
<?php

$result = mysql_query("SELECT * FROM `external_links`")or die ('אין דף כזה'.mysql_error());
			while($row = mysql_fetch_array($result))
			{
		echo "
			<form name=form action=# method=post enctype=multipart/form-data>
<table >
        <tr>
            <td>
            לינק:
            </td>
            <td >
             <input type=text  id=link name=link value='{$row['link']}' size=120 >
            <td>
   		</tr>
        <tr>
            <td>
            תיאור הלינק:
            </td>
            <td >
             <input type=text  id=link_desc name=link_desc value='{$row['link_desc']}' size=120 >
            <td>
   		</tr>
        <tr>
            <td>
            <input type=hidden name=linkID id=linkID value='{$row['id']}'>
            <input type=submit name=submit value=עדכן /> 
			<input type=submit name=submit value=מחק /> 
            </td>
    	</tr>
</table></form>";


			
			}
					

require_once("includes/closeConnection.php");	
?>
    
</contentText>
      </content>
</container>
    
     
    
</body>
</html>
